<!DOCTYPE html>
<html lang="en">

<head>
    <title>文章调教</title>

    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0">
    <meta name="author" content="Cononico" />
    <meta name="application-name" content="Spruche|文章调教" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="UTF-8" />
    <meta name="apple-mobile-app-capable" content="yes">
    <meta name="apple-mobile-app-status-bar-style" content="black">

    <meta name="description" itemprop="description" content="Spruche|文章调教" />
    <meta name="keywords" itemprop="keywords" content="二次元,绘画，宅,前端,Node" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="/stylesheets/libs/bootstrap.min.css" />
    <!--external css-->
    <link rel="stylesheet" href="/assets/font-awesome/css/font-awesome.css" />
    <!-- ueditor -->
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="/javascripts/libs/jquery-2.1.4.min.js"></script>
    <script src="/javascripts/libs/bootstrap.min.js"></script>

    <link rel='stylesheet' href='/dist/back.min.css' />
    <link rel="shortcut icon" type="image/x-icon" href="/images/icon/favicon.ico" />

    <script src="/ueditor/third-party/SyntaxHighlighter/shCore.js"></script>
    <link rel="stylesheet" href="/ueditor/third-party/SyntaxHighlighter/shCoreDefault.css">
    <script type="text/javascript">
        SyntaxHighlighter.all();
    </script>

</head>

<body>
    <div class="wirte-content" id="write-content" data-type="<%=edit%>" <% if(edit){ %>data-id="<%=blog.id%>"<% } %>>
        <form action="/admin/pblog" method="post" id="blog-form">
            <div class="wirte-div">
                <div class="blog-title-div">
                    <h1>文章调教</h1>
                    <% if(edit){ %>
                    <input id="blog-title-ipt" name="blog_title" value="<%=blog.title%>" > 
                    <% }else{ %>
                    <input id="blog-title-ipt" name="blog_title" > 
                    <% } %>
                </div>
                <% if(edit){ %>
                <textarea name="editor"  id="editor" style="width:100%;height:600px;"><%-blog.content%></textarea>
                <% } else {%>
                <script id="editor" type="text/plain" style="width:100%;height:600px;"></script>
                <% } %>
                <script>
                    var ue = UE.getEditor('editor',{
                    toolbars:[
                        ['fullscreen', 'source', 'undo', 'redo','inserttitle','horizontal','simpleupload','link','insertimage','music','emotion',
                        'spechars','backcolor','time','date','print','preview','help'],
                        ['fontsize','bold', 'italic','forecolor','underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 
                        'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'insertorderedlist', 'insertunorderedlist', 'imagecenter',
                        'lineheight','selectall', 'cleardoc','insertcode','paragraph'],
                        ['formatmatch','insertframe','autotypeset','charts','inserttable','map','gmap','attachment','deleterow','deletecol', 
                        'splittorows','splittocols','insertparagraphbeforetable']
                    ],
                    autoHeightEnabled: false,
                    autoFloatEnabled: true,
                });   
                </script>
            </div>
            <div class="write-bar">
                <div class="publish-opt-div">
                    <div class="publish-opt-title-div">
                        <h2>发布</h2>
                    </div>
                    <div class="publish-opt-btn-div">
                        <% if(edit) {%>
                        <button class="btn btn-default" type="button" id="alter-btn">更新文章</button>
                        <button class="btn btn-primary" type="button" id="update-btn">更新发布</button>
                        <% } else {%>
                        <button class="btn btn-default" type="button"   id="save-btn">保存草稿</button>
                        <button class="btn btn-primary" type="button" id="publish-btn">发布文章</button>
                        <% } %>
                    </div>
                </div>

                <div class="publish-opt-div">
                    <div class="publish-opt-title-div">
                        <h2>分类</h2>
                    </div>
                    <div class="publish-opt-title-div">
                        <ul class="classify-ul" id="classify-ul">
                            <% for(var i = 0; i < classify.length; i++){ %>
                            <% if(edit){ %>
                            <li class="classify-li"><input class="classify-ipt" name="classify" type="radio" <% if((i+1) == blog.classify_id) {%>checked<% } %> value="<%=classify[i].id %>" data-name="<%=classify[i].classify %>"/><span><%=classify[i].classify %></span></li>
                            <% } else {%>
                            <li class="classify-li"><input class="classify-ipt" name="classify" type="radio" <% if(i==0) {%>checked<% } %> value="<%=classify[i].id %>" data-name="<%=classify[i].classify %>"/><span><%=classify[i].classify %></span></li>
                            <% } %>
                            <% } %>
                        </ul>
                    </div>
                    <div class="publish-opt-btn-div">
                        <div class="input-group">
                            <input id="add-classify-ipt" type="text" class="form-control" placeholder="添加分类">
                            <span class="input-group-btn">
                                <button class="btn btn-default" id="add-classify" type="button">添加</button>
                            </span>
                        </div>
                    </div>
                </div>

                <div class="publish-opt-div">
                    <div class="publish-opt-title-div">
                        <h2>标签</h2>
                    </div>
                    <div class="publish-opt-btn-div">
                        <div class="input-group">
                            <input id="tags-ipt" type="text" class="form-control" placeholder="添加标签">
                            <span class="input-group-btn">
                                <button class="btn btn-default" id="add-tags" type="button">添加</button>
                            </span>
                        </div>
                        <div class="tips-div">
                            <p class="tips-p">多个标签请用英文逗号（,）分开</p>
                        </div>
                        <div id="tags-div" <%if(edit){%> data-tags="<%=blog.tags%>" <%}%> >
                            <%if(edit && blog.tags != ''){%>
                            <%var tags = blog.tags.split(',');%>
                            <% for(var t in tags){ %>
                            <a class="tags-a"><span class="glyphicon glyphicon-remove remove-tags"></span><span class="tags-span"><%=tags[t]%></span></a>
                            <% } %>
                            <%}%>
                        </div>                       
                    </div>
                </div>

                <div class="publish-opt-div">
                    <div class="publish-opt-title-div">
                        <h2>文章特色图片</h2>
                    </div>
                    <div>
                        <%if(edit) { %>
                        <img src="<%= blog.img %>" id="blog_img_show" class="img-thumbnail">
                        <% } %>
                    </div>
                     <div class="publish-opt-btn-div">
                         <a data-toggle="modal" data-target="#upload_blog_img_modal">上传图片</a>
                         <a data-toggle="modal" data-target="#write_blog_img_modal">图片地址</a>
                     </div>
                </div>
            </div>
            <div class="clearfix"></div>
        </form>
    </div>
    <div class="modal fade" tabindex="-1" role="dialog" id="upload_blog_img_modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">上传图片</h4>
                </div>
                <div class="modal-body">
                    <p>上传文章特色图片，文件大小在1M以下.</p>
                    <form class="form-inline" id="blog_img_form">
                        <div class="form-group">
                            <label for="blog_img_input">选择图片</label>
                            <input type="file" id="blog_img_input">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="blog_img_close_btn">Close</button>
                    <button type="button" class="btn btn-primary" id="blog_img_btn">OK</button>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" tabindex="-1" role="dialog" id="write_blog_img_modal">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">填写图片地址</h4>
                </div>
                <div class="modal-body">
                    <form id="write_blog_img_form">
                        <div class="form-group">
                            <label for="write_blog_img_input">图片地址</label>
                            <input class="form-control" type="text" id="write_blog_img_input">
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="write_blog_img_close_btn">Close</button>
                    <button type="button" class="btn btn-primary" id="write_blog_img_btn">OK</button>
                </div>
            </div>
        </div>
    </div>

    <script src="/dist/back.min.js"></script>
</body>
</html>